
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.knitr .inline {
  background-color: #f7f7f7;
  border:solid 1px #B0B0B0;
}
.error {
	font-weight: bold;
	color: #FF0000;
}
.warning {
	font-weight: bold;
}
.message {
	font-style: italic;
}
.source, .output, .warning, .error, .message {
	padding: 0 1em;
  border:solid 1px #F7F7F7;
}
.source {
  background-color: #f5f5f5;
}
.rimage .left {
  text-align: left;
}
.rimage .right {
  text-align: right;
}
.rimage .center {
  text-align: center;
}
.hl.num {
  color: #AF0F91;
}
.hl.str {
  color: #317ECC;
}
.hl.com {
  color: #AD95AF;
  font-style: italic;
}
.hl.opt {
  color: #000000;
}
.hl.std {
  color: #585858;
}
.hl.kwa {
  color: #295F94;
  font-weight: bold;
}
.hl.kwb {
  color: #B05A65;
}
.hl.kwc {
  color: #55aa55;
}
.hl.kwd {
  color: #BC5A65;
  font-weight: bold;
}
</style>
  <script src="https://yihui.name/media/js/center-images.js"></script>
  <title></title>
</head>
<body>

  <p>This report is automatically generated with the R
    package <a href="https://yihui.name/knitr/"><strong>knitr</strong></a>
    (version <code class="knitr inline">1.20</code>)
    .</p>

<div class="chunk" id="auto-report"><div class="rcode"><div class="source"><pre class="knitr r"><span class="hl com">## Packages ####################################################################</span>
<span class="hl kwd">library</span><span class="hl std">(</span><span class="hl str">&quot;coin&quot;</span><span class="hl std">)</span>
<span class="hl kwd">library</span><span class="hl std">(</span><span class="hl str">&quot;plm&quot;</span><span class="hl std">)</span>
<span class="hl kwd">library</span><span class="hl std">(</span><span class="hl str">&quot;lmtest&quot;</span><span class="hl std">)</span>
<span class="hl kwd">library</span><span class="hl std">(</span><span class="hl str">&quot;car&quot;</span><span class="hl std">)</span>
<span class="hl com">## library(&quot;memisc&quot;) loaded later</span>
<span class="hl kwd">set.seed</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">)</span>


<span class="hl com">## Convenience functions #######################################################</span>

<span class="hl com">## custom coefficient table</span>
<span class="hl std">cftable</span> <span class="hl kwb">&lt;-</span> <span class="hl kwa">function</span><span class="hl std">(</span><span class="hl kwc">obj</span><span class="hl std">,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;single&quot;</span><span class="hl std">,</span> <span class="hl kwc">var</span> <span class="hl std">=</span> <span class="hl str">&quot;st&quot;</span><span class="hl std">) {</span>
  <span class="hl std">str</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">sprintf</span><span class="hl std">(</span><span class="hl str">&quot;%s%s:&quot;</span><span class="hl std">, var, type)</span>
  <span class="hl std">cf</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">coeftest</span><span class="hl std">(obj,</span> <span class="hl kwc">vcov</span> <span class="hl std">= vcovBK)</span>
  <span class="hl std">ix</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">grep</span><span class="hl std">(str,</span> <span class="hl kwd">rownames</span><span class="hl std">(cf))</span>
  <span class="hl kwa">if</span><span class="hl std">((type</span> <span class="hl opt">==</span> <span class="hl str">&quot;team&quot;</span><span class="hl std">)</span> <span class="hl opt">&amp;&amp;</span> <span class="hl std">(</span><span class="hl str">&quot;twomaleyes&quot;</span> <span class="hl opt">%in%</span> <span class="hl kwd">rownames</span><span class="hl std">(cf))) ix</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">c</span><span class="hl std">(ix,</span> <span class="hl kwd">which</span><span class="hl std">(</span><span class="hl kwd">rownames</span><span class="hl std">(cf)</span> <span class="hl opt">==</span> <span class="hl str">&quot;twomaleyes&quot;</span><span class="hl std">))</span>
  <span class="hl std">rval</span> <span class="hl kwb">&lt;-</span> <span class="hl std">cf[ix, ,</span> <span class="hl kwc">drop</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">]</span>
  <span class="hl kwd">rownames</span><span class="hl std">(rval)</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">gsub</span><span class="hl std">(str,</span> <span class="hl str">&quot;&quot;</span><span class="hl std">,</span> <span class="hl kwd">rownames</span><span class="hl std">(rval),</span> <span class="hl kwc">fixed</span> <span class="hl std">=</span> <span class="hl num">TRUE</span><span class="hl std">)</span>
  <span class="hl kwd">class</span><span class="hl std">(rval)</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">class</span><span class="hl std">(cf)</span>
  <span class="hl kwd">attr</span><span class="hl std">(rval,</span> <span class="hl str">&quot;contrasts&quot;</span><span class="hl std">)</span> <span class="hl kwb">&lt;-</span> <span class="hl std">obj</span><span class="hl opt">$</span><span class="hl std">contrasts</span>
  <span class="hl kwd">attr</span><span class="hl std">(rval,</span> <span class="hl str">&quot;xlevels&quot;</span><span class="hl std">)</span> <span class="hl kwb">&lt;-</span> <span class="hl std">obj</span><span class="hl opt">$</span><span class="hl std">xlevels</span>
  <span class="hl kwd">attr</span><span class="hl std">(rval,</span> <span class="hl str">&quot;call&quot;</span><span class="hl std">)</span> <span class="hl kwb">&lt;-</span> <span class="hl std">obj</span><span class="hl opt">$</span><span class="hl std">call</span>
  <span class="hl kwd">attr</span><span class="hl std">(rval,</span> <span class="hl str">&quot;nobs&quot;</span><span class="hl std">)</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">as.numeric</span><span class="hl std">(</span><span class="hl kwd">rowSums</span><span class="hl std">(</span><span class="hl kwd">table</span><span class="hl std">(obj</span><span class="hl opt">$</span><span class="hl std">model[[var]],</span> <span class="hl kwd">attr</span><span class="hl std">(obj</span><span class="hl opt">$</span><span class="hl std">model,</span> <span class="hl str">&quot;index&quot;</span><span class="hl std">)</span><span class="hl opt">$</span><span class="hl std">teamid)</span> <span class="hl opt">&gt;</span> <span class="hl num">0</span><span class="hl std">)[type])</span>
  <span class="hl std">rval</span>
<span class="hl std">}</span>

<span class="hl com">## memisc::mtable plugin for custom coeftest table</span>
<span class="hl std">getSummary.coeftest</span> <span class="hl kwb">&lt;-</span> <span class="hl kwa">function</span><span class="hl std">(</span><span class="hl kwc">obj</span><span class="hl std">,</span> <span class="hl kwc">alpha</span> <span class="hl std">=</span> <span class="hl num">0.05</span><span class="hl std">,</span> <span class="hl kwc">...</span><span class="hl std">) {</span>
  <span class="hl com">## coefficient matrix and confidence interval</span>
  <span class="hl std">cf</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">cbind</span><span class="hl std">(obj, obj[,</span><span class="hl num">1</span><span class="hl std">]</span> <span class="hl opt">+</span> <span class="hl kwd">qnorm</span><span class="hl std">(alpha</span><span class="hl opt">/</span><span class="hl num">2</span><span class="hl std">)</span> <span class="hl opt">*</span> <span class="hl std">obj[,</span><span class="hl num">2</span><span class="hl std">], obj[,</span><span class="hl num">1</span><span class="hl std">]</span> <span class="hl opt">+</span> <span class="hl kwd">qnorm</span><span class="hl std">(</span><span class="hl num">1</span> <span class="hl opt">-</span> <span class="hl std">alpha</span><span class="hl opt">/</span><span class="hl num">2</span><span class="hl std">)</span> <span class="hl opt">*</span> <span class="hl std">obj[,</span><span class="hl num">2</span><span class="hl std">])</span>
  <span class="hl kwd">colnames</span><span class="hl std">(cf)</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;est&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;se&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;stat&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;p&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;lwr&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;upr&quot;</span><span class="hl std">)</span>

  <span class="hl com">## further summary statistics</span>
  <span class="hl std">sstat</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;N&quot;</span> <span class="hl std">=</span> <span class="hl kwd">attr</span><span class="hl std">(obj,</span> <span class="hl str">&quot;nobs&quot;</span><span class="hl std">))</span>

  <span class="hl com">## return everything</span>
  <span class="hl kwd">return</span><span class="hl std">(</span><span class="hl kwd">list</span><span class="hl std">(</span>
    <span class="hl kwc">coef</span> <span class="hl std">= cf,</span>
    <span class="hl kwc">sumstat</span> <span class="hl std">= sstat,</span>
    <span class="hl kwc">contrasts</span> <span class="hl std">=</span> <span class="hl kwd">attr</span><span class="hl std">(obj,</span> <span class="hl str">&quot;contrasts&quot;</span><span class="hl std">),</span>
    <span class="hl kwc">xlevels</span> <span class="hl std">=</span> <span class="hl kwd">attr</span><span class="hl std">(obj,</span> <span class="hl str">&quot;xlevels&quot;</span><span class="hl std">),</span>
    <span class="hl kwc">call</span> <span class="hl std">=</span> <span class="hl kwd">attr</span><span class="hl std">(obj,</span> <span class="hl str">&quot;call&quot;</span><span class="hl std">)</span>
  <span class="hl std">))</span>
<span class="hl std">}</span>


<span class="hl com">## Data ########################################################################</span>

<span class="hl com">## read CSV file</span>
<span class="hl std">mla</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">read.csv</span><span class="hl std">(</span><span class="hl str">&quot;MyopicLossAversion.csv&quot;</span><span class="hl std">)</span>

<span class="hl com">## for convenience: abbreviate treatment variable names</span>
<span class="hl kwd">names</span><span class="hl std">(mla)</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">gsub</span><span class="hl std">(</span><span class="hl str">&quot;treatment_&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;&quot;</span><span class="hl std">,</span> <span class="hl kwd">names</span><span class="hl std">(mla),</span> <span class="hl kwc">fixed</span> <span class="hl std">=</span> <span class="hl num">TRUE</span><span class="hl std">)</span>

<span class="hl com">## add payouts in each round</span>
<span class="hl kwa">for</span><span class="hl std">(i</span> <span class="hl kwa">in</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">9</span><span class="hl std">) mla[[</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;payout&quot;</span><span class="hl std">, i)]]</span> <span class="hl kwb">&lt;-</span> <span class="hl std">(</span><span class="hl num">100</span> <span class="hl opt">-</span> <span class="hl std">mla[[</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;invest&quot;</span><span class="hl std">, i)]])</span> <span class="hl opt">+</span>
  <span class="hl std">mla[[</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;win&quot;</span><span class="hl std">, i)]]</span> <span class="hl opt">*</span> <span class="hl num">3.5</span> <span class="hl opt">*</span> <span class="hl std">mla[[</span><span class="hl kwd">paste0</span><span class="hl std">(</span><span class="hl str">&quot;invest&quot;</span><span class="hl std">, i)]]</span>

<span class="hl com">## add transformed covariates</span>
<span class="hl std">mla</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">transform</span><span class="hl std">(mla,</span>

  <span class="hl com">## cumulative wins in all previous rounds</span>
  <span class="hl kwc">cwin1</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">cwin2</span> <span class="hl std">= win1,</span>
  <span class="hl kwc">cwin3</span> <span class="hl std">= win1</span> <span class="hl opt">+</span> <span class="hl std">win2,</span>
  <span class="hl kwc">cwin4</span> <span class="hl std">= win1</span> <span class="hl opt">+</span> <span class="hl std">win2</span> <span class="hl opt">+</span> <span class="hl std">win3,</span>
  <span class="hl kwc">cwin5</span> <span class="hl std">= win1</span> <span class="hl opt">+</span> <span class="hl std">win2</span> <span class="hl opt">+</span> <span class="hl std">win3</span> <span class="hl opt">+</span> <span class="hl std">win4,</span>
  <span class="hl kwc">cwin6</span> <span class="hl std">= win1</span> <span class="hl opt">+</span> <span class="hl std">win2</span> <span class="hl opt">+</span> <span class="hl std">win3</span> <span class="hl opt">+</span> <span class="hl std">win4</span> <span class="hl opt">+</span> <span class="hl std">win5,</span>
  <span class="hl kwc">cwin7</span> <span class="hl std">= win1</span> <span class="hl opt">+</span> <span class="hl std">win2</span> <span class="hl opt">+</span> <span class="hl std">win3</span> <span class="hl opt">+</span> <span class="hl std">win4</span> <span class="hl opt">+</span> <span class="hl std">win5</span> <span class="hl opt">+</span> <span class="hl std">win6,</span>
  <span class="hl kwc">cwin8</span> <span class="hl std">= win1</span> <span class="hl opt">+</span> <span class="hl std">win2</span> <span class="hl opt">+</span> <span class="hl std">win3</span> <span class="hl opt">+</span> <span class="hl std">win4</span> <span class="hl opt">+</span> <span class="hl std">win5</span> <span class="hl opt">+</span> <span class="hl std">win6</span> <span class="hl opt">+</span> <span class="hl std">win7,</span>
  <span class="hl kwc">cwin9</span> <span class="hl std">= win1</span> <span class="hl opt">+</span> <span class="hl std">win2</span> <span class="hl opt">+</span> <span class="hl std">win3</span> <span class="hl opt">+</span> <span class="hl std">win4</span> <span class="hl opt">+</span> <span class="hl std">win5</span> <span class="hl opt">+</span> <span class="hl std">win6</span> <span class="hl opt">+</span> <span class="hl std">win7</span> <span class="hl opt">+</span> <span class="hl std">win8,</span>

  <span class="hl com">## lagged wins in last previous round</span>
  <span class="hl kwc">lwin1</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">lwin2</span> <span class="hl std">= win1,</span>
  <span class="hl kwc">lwin3</span> <span class="hl std">= win2,</span>
  <span class="hl kwc">lwin4</span> <span class="hl std">= win3,</span>
  <span class="hl kwc">lwin5</span> <span class="hl std">= win4,</span>
  <span class="hl kwc">lwin6</span> <span class="hl std">= win5,</span>
  <span class="hl kwc">lwin7</span> <span class="hl std">= win6,</span>
  <span class="hl kwc">lwin8</span> <span class="hl std">= win7,</span>
  <span class="hl kwc">lwin9</span> <span class="hl std">= win8,</span>

  <span class="hl com">## wins in last block</span>
  <span class="hl kwc">bwin1</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bwin2</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bwin3</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bwin4</span> <span class="hl std">= win1</span> <span class="hl opt">+</span> <span class="hl std">win2</span> <span class="hl opt">+</span> <span class="hl std">win3,</span>
  <span class="hl kwc">bwin5</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bwin6</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bwin7</span> <span class="hl std">= win4</span> <span class="hl opt">+</span> <span class="hl std">win5</span> <span class="hl opt">+</span> <span class="hl std">win6,</span>
  <span class="hl kwc">bwin8</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bwin9</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>

  <span class="hl com">## cumulative wins in all previous rounds</span>
  <span class="hl kwc">cpayout1</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">cpayout2</span> <span class="hl std">= payout1,</span>
  <span class="hl kwc">cpayout3</span> <span class="hl std">= payout1</span> <span class="hl opt">+</span> <span class="hl std">payout2,</span>
  <span class="hl kwc">cpayout4</span> <span class="hl std">= payout1</span> <span class="hl opt">+</span> <span class="hl std">payout2</span> <span class="hl opt">+</span> <span class="hl std">payout3,</span>
  <span class="hl kwc">cpayout5</span> <span class="hl std">= payout1</span> <span class="hl opt">+</span> <span class="hl std">payout2</span> <span class="hl opt">+</span> <span class="hl std">payout3</span> <span class="hl opt">+</span> <span class="hl std">payout4,</span>
  <span class="hl kwc">cpayout6</span> <span class="hl std">= payout1</span> <span class="hl opt">+</span> <span class="hl std">payout2</span> <span class="hl opt">+</span> <span class="hl std">payout3</span> <span class="hl opt">+</span> <span class="hl std">payout4</span> <span class="hl opt">+</span> <span class="hl std">payout5,</span>
  <span class="hl kwc">cpayout7</span> <span class="hl std">= payout1</span> <span class="hl opt">+</span> <span class="hl std">payout2</span> <span class="hl opt">+</span> <span class="hl std">payout3</span> <span class="hl opt">+</span> <span class="hl std">payout4</span> <span class="hl opt">+</span> <span class="hl std">payout5</span> <span class="hl opt">+</span> <span class="hl std">payout6,</span>
  <span class="hl kwc">cpayout8</span> <span class="hl std">= payout1</span> <span class="hl opt">+</span> <span class="hl std">payout2</span> <span class="hl opt">+</span> <span class="hl std">payout3</span> <span class="hl opt">+</span> <span class="hl std">payout4</span> <span class="hl opt">+</span> <span class="hl std">payout5</span> <span class="hl opt">+</span> <span class="hl std">payout6</span> <span class="hl opt">+</span> <span class="hl std">payout7,</span>
  <span class="hl kwc">cpayout9</span> <span class="hl std">= payout1</span> <span class="hl opt">+</span> <span class="hl std">payout2</span> <span class="hl opt">+</span> <span class="hl std">payout3</span> <span class="hl opt">+</span> <span class="hl std">payout4</span> <span class="hl opt">+</span> <span class="hl std">payout5</span> <span class="hl opt">+</span> <span class="hl std">payout6</span> <span class="hl opt">+</span> <span class="hl std">payout7</span> <span class="hl opt">+</span> <span class="hl std">payout8,</span>

  <span class="hl com">## lagged payouts in last previous round</span>
  <span class="hl kwc">lpayout1</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">lpayout2</span> <span class="hl std">= payout1,</span>
  <span class="hl kwc">lpayout3</span> <span class="hl std">= payout2,</span>
  <span class="hl kwc">lpayout4</span> <span class="hl std">= payout3,</span>
  <span class="hl kwc">lpayout5</span> <span class="hl std">= payout4,</span>
  <span class="hl kwc">lpayout6</span> <span class="hl std">= payout5,</span>
  <span class="hl kwc">lpayout7</span> <span class="hl std">= payout6,</span>
  <span class="hl kwc">lpayout8</span> <span class="hl std">= payout7,</span>
  <span class="hl kwc">lpayout9</span> <span class="hl std">= payout8,</span>

  <span class="hl com">## payouts in last block</span>
  <span class="hl kwc">bpayout1</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bpayout2</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bpayout3</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bpayout4</span> <span class="hl std">= payout1</span> <span class="hl opt">+</span> <span class="hl std">payout2</span> <span class="hl opt">+</span> <span class="hl std">payout3,</span>
  <span class="hl kwc">bpayout5</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bpayout6</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bpayout7</span> <span class="hl std">= payout4</span> <span class="hl opt">+</span> <span class="hl std">payout5</span> <span class="hl opt">+</span> <span class="hl std">payout6,</span>
  <span class="hl kwc">bpayout8</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>
  <span class="hl kwc">bpayout9</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">,</span>

  <span class="hl com">## (re-)level categorical covariates</span>
  <span class="hl kwc">gender</span>   <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(gender,</span> <span class="hl kwc">levels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;male&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;female&quot;</span><span class="hl std">)),</span>
  <span class="hl kwc">school</span>   <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(school),</span>
  <span class="hl kwc">yo</span>       <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(yo,</span> <span class="hl kwc">levels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Younger&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Older&quot;</span><span class="hl std">)),</span>

  <span class="hl com">## age centered: approximately within age group</span>
  <span class="hl kwc">age_yo</span>   <span class="hl std">= age</span> <span class="hl opt">-</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">17</span><span class="hl std">,</span> <span class="hl num">12</span><span class="hl std">)[yo]</span>
<span class="hl std">)</span>

<span class="hl com">## additional IDs for single players (to facilitate subsequent aggregation)</span>
<span class="hl std">mla</span><span class="hl opt">$</span><span class="hl std">teamid[</span><span class="hl kwd">is.na</span><span class="hl std">(mla</span><span class="hl opt">$</span><span class="hl std">teamid)]</span> <span class="hl kwb">&lt;-</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl kwd">sum</span><span class="hl std">(</span><span class="hl kwd">is.na</span><span class="hl std">(mla</span><span class="hl opt">$</span><span class="hl std">teamid))</span> <span class="hl opt">+</span> <span class="hl kwd">max</span><span class="hl std">(mla</span><span class="hl opt">$</span><span class="hl std">teamid,</span> <span class="hl kwc">na.rm</span> <span class="hl std">=</span> <span class="hl num">TRUE</span><span class="hl std">)</span>
<span class="hl std">mla</span><span class="hl opt">$</span><span class="hl std">teamid</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">factor</span><span class="hl std">(mla</span><span class="hl opt">$</span><span class="hl std">teamid)</span>

<span class="hl com">## aggregate within teams</span>
<span class="hl com">## categorical variables</span>
<span class="hl std">amla</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(mla,</span> <span class="hl kwd">data.frame</span><span class="hl std">(</span>
  <span class="hl kwc">teamid</span> <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(</span><span class="hl kwd">tapply</span><span class="hl std">(teamid, teamid, unique),</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(teamid)),</span>
  <span class="hl kwc">lh</span> <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(</span><span class="hl kwd">tapply</span><span class="hl std">(lh, teamid, unique),</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(lh)),</span>
  <span class="hl kwc">yo</span> <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(</span><span class="hl kwd">tapply</span><span class="hl std">(yo, teamid, unique),</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(yo)),</span>
  <span class="hl kwc">st</span> <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(</span><span class="hl kwd">tapply</span><span class="hl std">(st, teamid, unique),</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(st)),</span>
  <span class="hl kwc">school</span> <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(</span><span class="hl kwd">tapply</span><span class="hl std">(school, teamid, unique),</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(school)),</span>
  <span class="hl kwc">gender</span> <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(</span><span class="hl kwd">tapply</span><span class="hl std">(gender, teamid,</span> <span class="hl kwa">function</span><span class="hl std">(</span><span class="hl kwc">x</span><span class="hl std">)</span> <span class="hl kwa">if</span><span class="hl std">(</span><span class="hl kwd">length</span><span class="hl std">(x)</span> <span class="hl opt">&gt;</span> <span class="hl num">1</span> <span class="hl opt">&amp;&amp;</span> <span class="hl std">x[</span><span class="hl num">1</span><span class="hl std">]</span> <span class="hl opt">!=</span> <span class="hl std">x[</span><span class="hl num">2</span><span class="hl std">])</span> <span class="hl str">&quot;female/male&quot;</span> <span class="hl kwa">else</span> <span class="hl kwd">as.character</span><span class="hl std">(x)[</span><span class="hl num">1</span><span class="hl std">])),</span>
  <span class="hl kwc">male</span> <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(</span><span class="hl kwd">tapply</span><span class="hl std">(gender, teamid,</span> <span class="hl kwa">function</span><span class="hl std">(</span><span class="hl kwc">x</span><span class="hl std">)</span> <span class="hl str">&quot;male&quot;</span> <span class="hl opt">%in%</span> <span class="hl std">x),</span> <span class="hl kwc">levels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">FALSE</span><span class="hl std">,</span> <span class="hl num">TRUE</span><span class="hl std">),</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;no&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;yes&quot;</span><span class="hl std">)),</span>
  <span class="hl kwc">twomale</span> <span class="hl std">=</span> <span class="hl kwd">factor</span><span class="hl std">(</span><span class="hl kwd">tapply</span><span class="hl std">(gender, teamid,</span> <span class="hl kwa">function</span><span class="hl std">(</span><span class="hl kwc">x</span><span class="hl std">)</span> <span class="hl kwa">if</span><span class="hl std">(</span><span class="hl kwd">length</span><span class="hl std">(x)</span> <span class="hl opt">&gt;</span> <span class="hl num">1</span> <span class="hl opt">&amp;&amp;</span> <span class="hl std">x[</span><span class="hl num">1</span><span class="hl std">]</span> <span class="hl opt">==</span> <span class="hl std">x[</span><span class="hl num">2</span><span class="hl std">]</span> <span class="hl opt">&amp;&amp;</span> <span class="hl std">x[</span><span class="hl num">1</span><span class="hl std">]</span> <span class="hl opt">==</span> <span class="hl str">&quot;male&quot;</span><span class="hl std">)</span> <span class="hl str">&quot;yes&quot;</span> <span class="hl kwa">else</span> <span class="hl str">&quot;no&quot;</span><span class="hl std">))</span>
<span class="hl std">))</span>
<span class="hl com">## numeric variables</span>
<span class="hl kwa">for</span><span class="hl std">(n</span> <span class="hl kwa">in</span> <span class="hl kwd">names</span><span class="hl std">(mla)[</span><span class="hl kwd">which</span><span class="hl std">(</span><span class="hl kwd">sapply</span><span class="hl std">(mla, is.numeric))]) amla[[n]]</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">as.vector</span><span class="hl std">(</span><span class="hl kwd">tapply</span><span class="hl std">(mla[[n]], mla[[</span><span class="hl str">&quot;teamid&quot;</span><span class="hl std">]], mean))</span>


<span class="hl com">## reshape into &quot;long&quot; format</span>
<span class="hl std">var</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">grep</span><span class="hl std">(</span><span class="hl str">&quot;[1-9]&quot;</span><span class="hl std">,</span> <span class="hl kwd">names</span><span class="hl std">(amla))</span>
<span class="hl std">vnm</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">names</span><span class="hl std">(amla)[var]</span>
<span class="hl std">vnm</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">gsub</span><span class="hl std">(</span><span class="hl str">&quot;[1-9]&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;&quot;</span><span class="hl std">, vnm)</span>
<span class="hl std">lmla</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">reshape</span><span class="hl std">(amla,</span> <span class="hl kwc">direction</span> <span class="hl std">=</span> <span class="hl str">&quot;long&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">idvar</span> <span class="hl std">=</span> <span class="hl str">&quot;teamid&quot;</span><span class="hl std">,</span> <span class="hl kwc">timevar</span> <span class="hl std">=</span> <span class="hl str">&quot;round&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">varying</span> <span class="hl std">=</span> <span class="hl kwd">split</span><span class="hl std">(var,</span> <span class="hl kwd">factor</span><span class="hl std">(vnm,</span> <span class="hl kwc">levels</span> <span class="hl std">=</span> <span class="hl kwd">unique</span><span class="hl std">(vnm))),</span>
  <span class="hl kwc">v.names</span> <span class="hl std">=</span> <span class="hl kwd">unique</span><span class="hl std">(vnm))</span>
<span class="hl std">lmla</span> <span class="hl kwb">&lt;-</span> <span class="hl std">lmla[</span><span class="hl kwd">order</span><span class="hl std">(lmla</span><span class="hl opt">$</span><span class="hl std">teamid),]</span>
<span class="hl std">lmla</span><span class="hl opt">$</span><span class="hl std">age</span> <span class="hl kwb">&lt;-</span> <span class="hl std">lmla</span><span class="hl opt">$</span><span class="hl std">age_yo</span>


<span class="hl com">## for subjects in LONG treatment use lwin = bwin / lpayout = bpayout</span>
<span class="hl std">lmla</span><span class="hl opt">$</span><span class="hl std">lwin[lmla</span><span class="hl opt">$</span><span class="hl std">lh</span> <span class="hl opt">==</span> <span class="hl str">&quot;LONG&quot;</span><span class="hl std">]</span> <span class="hl kwb">&lt;-</span> <span class="hl std">lmla</span><span class="hl opt">$</span><span class="hl std">bwin[lmla</span><span class="hl opt">$</span><span class="hl std">lh</span> <span class="hl opt">==</span> <span class="hl str">&quot;LONG&quot;</span><span class="hl std">]</span> <span class="hl opt">/</span> <span class="hl num">3</span>
<span class="hl std">lmla</span><span class="hl opt">$</span><span class="hl std">lpayout[lmla</span><span class="hl opt">$</span><span class="hl std">lh</span> <span class="hl opt">==</span> <span class="hl str">&quot;LONG&quot;</span><span class="hl std">]</span> <span class="hl kwb">&lt;-</span> <span class="hl std">lmla</span><span class="hl opt">$</span><span class="hl std">bpayout[lmla</span><span class="hl opt">$</span><span class="hl std">lh</span> <span class="hl opt">==</span> <span class="hl str">&quot;LONG&quot;</span><span class="hl std">]</span> <span class="hl opt">/</span> <span class="hl num">3</span>
<span class="hl com">## omit LONG investment decision in non-decision rounds</span>
<span class="hl std">lmla</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">subset</span><span class="hl std">(lmla, lh</span> <span class="hl opt">==</span> <span class="hl str">&quot;SHORT&quot;</span> <span class="hl opt">|</span> <span class="hl std">round</span> <span class="hl opt">%in%</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">4</span><span class="hl std">,</span> <span class="hl num">7</span><span class="hl std">))</span>
<span class="hl std">lmla</span><span class="hl opt">$</span><span class="hl std">round</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">as.numeric</span><span class="hl std">(lmla</span><span class="hl opt">$</span><span class="hl std">round)</span>


<span class="hl com">## panel data _with_ first round</span>
<span class="hl std">pmla</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">pdata.frame</span><span class="hl std">(lmla,</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;teamid&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;round&quot;</span><span class="hl std">))</span>


<span class="hl com">## and omitting first round</span>
<span class="hl std">pmla1</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">pdata.frame</span><span class="hl std">(</span><span class="hl kwd">subset</span><span class="hl std">(lmla, round</span> <span class="hl opt">&gt;</span> <span class="hl num">1</span><span class="hl std">),</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;teamid&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;round&quot;</span><span class="hl std">))</span>


<span class="hl com">## table needed later for Figure 2 (but needs to be computed before attaching memisc)</span>
<span class="hl std">nd2e</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">aggregate</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl std">st</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">+</span> <span class="hl std">male,</span> <span class="hl kwc">data</span> <span class="hl std">= pmla,</span> <span class="hl kwc">FUN</span> <span class="hl std">= mean)</span>


<span class="hl com">## Table 1 #####################################################################</span>
<span class="hl kwd">ftable</span><span class="hl std">(</span><span class="hl kwd">xtabs</span><span class="hl std">(</span><span class="hl opt">~</span> <span class="hl std">yo</span> <span class="hl opt">+</span> <span class="hl std">st</span> <span class="hl opt">+</span> <span class="hl std">lh,</span> <span class="hl kwc">data</span> <span class="hl std">= mla)[, ,</span><span class="hl num">2</span><span class="hl opt">:</span><span class="hl num">1</span><span class="hl std">])</span>
</pre></div>
<div class="output"><pre class="knitr r">##                lh SHORT LONG
## yo      st                  
## Younger single      116  110
##         team        114  116
## Older   single       71   88
##         team         82   58
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com">## Table 2 #####################################################################</span>
<span class="hl std">tab2</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(amla,</span> <span class="hl kwd">tapply</span><span class="hl std">(minvest,</span> <span class="hl kwd">interaction</span><span class="hl std">(lh, st, yo),</span> <span class="hl kwa">function</span><span class="hl std">(</span><span class="hl kwc">x</span><span class="hl std">)</span>
  <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Mean&quot;</span> <span class="hl std">=</span> <span class="hl kwd">mean</span><span class="hl std">(x),</span> <span class="hl str">&quot;Median&quot;</span> <span class="hl std">=</span> <span class="hl kwd">median</span><span class="hl std">(x),</span> <span class="hl str">&quot;St. dev.&quot;</span> <span class="hl std">=</span> <span class="hl kwd">sqrt</span><span class="hl std">(</span><span class="hl kwd">var</span><span class="hl std">(x)</span><span class="hl opt">/</span><span class="hl kwd">length</span><span class="hl std">(x)),</span> <span class="hl str">&quot;# units&quot;</span> <span class="hl std">=</span> <span class="hl kwd">length</span><span class="hl std">(x))))</span>
<span class="hl std">tab2</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">do.call</span><span class="hl std">(</span><span class="hl str">&quot;cbind&quot;</span><span class="hl std">, tab2)</span>
<span class="hl kwd">round</span><span class="hl std">(tab2,</span> <span class="hl kwc">digits</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">##          LONG.single.Younger SHORT.single.Younger LONG.team.Younger SHORT.team.Younger
## Mean                   43.77                48.31             57.86              56.23
## Median                 43.17                49.61             61.67              58.33
## St. dev.                2.36                 2.39              2.93               3.03
## # units               110.00               116.00             58.00              57.00
##          LONG.single.Older SHORT.single.Older LONG.team.Older SHORT.team.Older
## Mean                 41.32              46.12           73.99            65.36
## Median               43.33              44.44           77.33            64.44
## St. dev.              2.78               3.45            4.49             4.19
## # units              88.00              71.00           29.00            41.00
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com">## Nonparametric inference (Section 3.1) #######################################</span>

<span class="hl com">## first analysis of myopic loss aversion using nonparametric tests</span>
<span class="hl kwd">wilcox_test</span><span class="hl std">(minvest</span> <span class="hl opt">~</span> <span class="hl std">lh,</span> <span class="hl kwc">data</span> <span class="hl std">= amla,</span> <span class="hl kwc">subset</span> <span class="hl std">= amla</span><span class="hl opt">$</span><span class="hl std">yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">amla</span><span class="hl opt">$</span><span class="hl std">st</span> <span class="hl opt">==</span> <span class="hl str">&quot;single&quot;</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## 	Asymptotic Wilcoxon-Mann-Whitney Test
## 
## data:  minvest by lh (LONG, SHORT)
## Z = -1.3141, p-value = 0.1888
## alternative hypothesis: true mu is not equal to 0
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">wilcox_test</span><span class="hl std">(minvest</span> <span class="hl opt">~</span> <span class="hl std">lh,</span> <span class="hl kwc">data</span> <span class="hl std">= amla,</span> <span class="hl kwc">subset</span> <span class="hl std">= amla</span><span class="hl opt">$</span><span class="hl std">yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span>   <span class="hl opt">&amp;</span> <span class="hl std">amla</span><span class="hl opt">$</span><span class="hl std">st</span> <span class="hl opt">==</span> <span class="hl str">&quot;single&quot;</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## 	Asymptotic Wilcoxon-Mann-Whitney Test
## 
## data:  minvest by lh (LONG, SHORT)
## Z = -0.83543, p-value = 0.4035
## alternative hypothesis: true mu is not equal to 0
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">wilcox_test</span><span class="hl std">(minvest</span> <span class="hl opt">~</span> <span class="hl std">lh,</span> <span class="hl kwc">data</span> <span class="hl std">= amla,</span> <span class="hl kwc">subset</span> <span class="hl std">= amla</span><span class="hl opt">$</span><span class="hl std">yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">amla</span><span class="hl opt">$</span><span class="hl std">st</span> <span class="hl opt">==</span> <span class="hl str">&quot;team&quot;</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## 	Asymptotic Wilcoxon-Mann-Whitney Test
## 
## data:  minvest by lh (LONG, SHORT)
## Z = 0.26857, p-value = 0.7883
## alternative hypothesis: true mu is not equal to 0
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">wilcox_test</span><span class="hl std">(minvest</span> <span class="hl opt">~</span> <span class="hl std">lh,</span> <span class="hl kwc">data</span> <span class="hl std">= amla,</span> <span class="hl kwc">subset</span> <span class="hl std">= amla</span><span class="hl opt">$</span><span class="hl std">yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span>   <span class="hl opt">&amp;</span> <span class="hl std">amla</span><span class="hl opt">$</span><span class="hl std">st</span> <span class="hl opt">==</span> <span class="hl str">&quot;team&quot;</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## 	Asymptotic Wilcoxon-Mann-Whitney Test
## 
## data:  minvest by lh (LONG, SHORT)
## Z = 1.2342, p-value = 0.2171
## alternative hypothesis: true mu is not equal to 0
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com">## and analysis of team effect</span>
<span class="hl kwd">wilcox_test</span><span class="hl std">(minvest</span> <span class="hl opt">~</span> <span class="hl std">st,</span> <span class="hl kwc">data</span> <span class="hl std">= amla,</span> <span class="hl kwc">subset</span> <span class="hl std">= amla</span><span class="hl opt">$</span><span class="hl std">yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">amla</span><span class="hl opt">$</span><span class="hl std">lh</span> <span class="hl opt">==</span> <span class="hl str">&quot;SHORT&quot;</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## 	Asymptotic Wilcoxon-Mann-Whitney Test
## 
## data:  minvest by st (single, team)
## Z = -2.1204, p-value = 0.03398
## alternative hypothesis: true mu is not equal to 0
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">wilcox_test</span><span class="hl std">(minvest</span> <span class="hl opt">~</span> <span class="hl std">st,</span> <span class="hl kwc">data</span> <span class="hl std">= amla,</span> <span class="hl kwc">subset</span> <span class="hl std">= amla</span><span class="hl opt">$</span><span class="hl std">yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span>   <span class="hl opt">&amp;</span> <span class="hl std">amla</span><span class="hl opt">$</span><span class="hl std">lh</span> <span class="hl opt">==</span> <span class="hl str">&quot;SHORT&quot;</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## 	Asymptotic Wilcoxon-Mann-Whitney Test
## 
## data:  minvest by st (single, team)
## Z = -3.3226, p-value = 0.000892
## alternative hypothesis: true mu is not equal to 0
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">wilcox_test</span><span class="hl std">(minvest</span> <span class="hl opt">~</span> <span class="hl std">st,</span> <span class="hl kwc">data</span> <span class="hl std">= amla,</span> <span class="hl kwc">subset</span> <span class="hl std">= amla</span><span class="hl opt">$</span><span class="hl std">yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">amla</span><span class="hl opt">$</span><span class="hl std">lh</span> <span class="hl opt">==</span> <span class="hl str">&quot;LONG&quot;</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## 	Asymptotic Wilcoxon-Mann-Whitney Test
## 
## data:  minvest by st (single, team)
## Z = -3.5325, p-value = 0.0004116
## alternative hypothesis: true mu is not equal to 0
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">wilcox_test</span><span class="hl std">(minvest</span> <span class="hl opt">~</span> <span class="hl std">st,</span> <span class="hl kwc">data</span> <span class="hl std">= amla,</span> <span class="hl kwc">subset</span> <span class="hl std">= amla</span><span class="hl opt">$</span><span class="hl std">yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span>   <span class="hl opt">&amp;</span> <span class="hl std">amla</span><span class="hl opt">$</span><span class="hl std">lh</span> <span class="hl opt">==</span> <span class="hl str">&quot;LONG&quot;</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## 	Asymptotic Wilcoxon-Mann-Whitney Test
## 
## data:  minvest by st (single, team)
## Z = -5.0275, p-value = 4.968e-07
## alternative hypothesis: true mu is not equal to 0
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com">## Figure 1 ######################################</span>

<span class="hl com">## empirical quantities from Table 2</span>
<span class="hl std">mn</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(amla,</span> <span class="hl kwd">tapply</span><span class="hl std">(minvest,</span> <span class="hl kwd">list</span><span class="hl std">(st, lh, yo), mean))[,</span><span class="hl num">2</span><span class="hl opt">:</span><span class="hl num">1</span><span class="hl std">,]</span>
<span class="hl std">md</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(amla,</span> <span class="hl kwd">tapply</span><span class="hl std">(minvest,</span> <span class="hl kwd">list</span><span class="hl std">(st, lh, yo), median))[,</span><span class="hl num">2</span><span class="hl opt">:</span><span class="hl num">1</span><span class="hl std">,]</span>
<span class="hl std">se</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(amla,</span> <span class="hl kwd">tapply</span><span class="hl std">(minvest,</span> <span class="hl kwd">list</span><span class="hl std">(st, lh, yo),</span> <span class="hl kwa">function</span><span class="hl std">(</span><span class="hl kwc">x</span><span class="hl std">)</span> <span class="hl kwd">sqrt</span><span class="hl std">(</span><span class="hl kwd">var</span><span class="hl std">(x)</span><span class="hl opt">/</span><span class="hl kwd">length</span><span class="hl std">(x))))[,</span><span class="hl num">2</span><span class="hl opt">:</span><span class="hl num">1</span><span class="hl std">,]</span>

<span class="hl com">## payouts (me, se): overall, by yo, by st * yo * lh</span>
<span class="hl std">meanse</span> <span class="hl kwb">&lt;-</span> <span class="hl kwa">function</span><span class="hl std">(</span><span class="hl kwc">x</span><span class="hl std">,</span> <span class="hl kwc">digits</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">)</span> <span class="hl kwd">paste</span><span class="hl std">(</span><span class="hl kwd">format</span><span class="hl std">(</span><span class="hl kwd">round</span><span class="hl std">(</span><span class="hl kwd">mean</span><span class="hl std">(x),</span> <span class="hl kwc">digits</span> <span class="hl std">= digits),</span> <span class="hl kwc">nsmall</span> <span class="hl std">= digits),</span>
  <span class="hl str">&quot; (&quot;</span><span class="hl std">,</span> <span class="hl kwd">format</span><span class="hl std">(</span><span class="hl kwd">round</span><span class="hl std">(</span><span class="hl kwd">sd</span><span class="hl std">(x),</span> <span class="hl kwc">digits</span> <span class="hl std">= digits),</span> <span class="hl kwc">nsmall</span> <span class="hl std">= digits),</span> <span class="hl str">&quot;)&quot;</span><span class="hl std">,</span> <span class="hl kwc">sep</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">)</span>
<span class="hl std">amla</span><span class="hl opt">$</span><span class="hl std">payout</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">rowSums</span><span class="hl std">(amla[,</span> <span class="hl kwd">paste</span><span class="hl std">(</span><span class="hl str">&quot;payout&quot;</span><span class="hl std">,</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">9</span><span class="hl std">,</span> <span class="hl kwc">sep</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">)])</span>
<span class="hl std">pay1</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(amla,</span> <span class="hl kwd">meanse</span><span class="hl std">(payout))</span>
<span class="hl std">pay2</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(amla,</span> <span class="hl kwd">tapply</span><span class="hl std">(payout, yo, meanse))</span>
<span class="hl std">pay8</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(amla,</span> <span class="hl kwd">tapply</span><span class="hl std">(payout,</span> <span class="hl kwd">list</span><span class="hl std">(st, lh, yo), meanse))[,</span><span class="hl num">2</span><span class="hl opt">:</span><span class="hl num">1</span><span class="hl std">,]</span>
<span class="hl kwd">ftable</span><span class="hl std">(pay8,</span> <span class="hl kwc">col.vars</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">##                        single           team
##                                             
## SHORT Younger  968.5 (272.6)  965.8 (385.1) 
##       Older    962.5 (297.4)  861.5 (313.7) 
## LONG  Younger  966.5 (219.8)  991.3 (349.7) 
##       Older    991.9 (281.1)  1049.4 (393.0)
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com"># rb &lt;- hcl(c(0, 260), 40, 70, fixup = FALSE)</span>
<span class="hl std">rb</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">gray</span><span class="hl std">(</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0.75</span><span class="hl std">,</span> <span class="hl num">0.35</span><span class="hl std">))</span>
<span class="hl kwd">par</span><span class="hl std">(</span><span class="hl kwc">mfrow</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">),</span> <span class="hl kwc">mar</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">3</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">3</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">),</span> <span class="hl kwc">oma</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">4</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">3</span><span class="hl std">),</span> <span class="hl kwc">yaxs</span> <span class="hl std">=</span> <span class="hl str">&quot;i&quot;</span><span class="hl std">)</span>
<span class="hl kwd">plot</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl kwc">xlim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0.8</span><span class="hl std">,</span> <span class="hl num">6.2</span><span class="hl std">),</span> <span class="hl kwc">ylim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">80</span><span class="hl std">),</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;n&quot;</span><span class="hl std">,</span> <span class="hl kwc">axes</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">,</span> <span class="hl kwc">xlab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">,</span> <span class="hl kwc">ylab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">)</span>
<span class="hl kwd">abline</span><span class="hl std">(</span><span class="hl kwc">h</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">8</span> <span class="hl opt">*</span> <span class="hl num">10</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">=</span> <span class="hl str">&quot;lightgray&quot;</span><span class="hl std">)</span>
<span class="hl std">xat</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">barplot</span><span class="hl std">(mn[,,</span><span class="hl num">1</span><span class="hl std">],</span> <span class="hl kwc">beside</span> <span class="hl std">=</span> <span class="hl num">TRUE</span><span class="hl std">,</span> <span class="hl kwc">ylim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">80</span><span class="hl std">),</span>
  <span class="hl kwc">main</span> <span class="hl std">=</span> <span class="hl str">&quot;Younger group&quot;</span><span class="hl std">,</span> <span class="hl kwc">names</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;SHORT&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;LONG&quot;</span><span class="hl std">),</span>
  <span class="hl kwc">col</span> <span class="hl std">= rb,</span> <span class="hl kwc">add</span> <span class="hl std">=</span> <span class="hl num">TRUE</span><span class="hl std">,</span> <span class="hl kwc">axes</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">)</span>
<span class="hl kwa">for</span><span class="hl std">(i</span> <span class="hl kwa">in</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">) {</span> <span class="hl kwa">for</span><span class="hl std">(j</span> <span class="hl kwa">in</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">) {</span>
  <span class="hl kwd">arrows</span><span class="hl std">(xat[i,j], mn[i,j,</span><span class="hl num">1</span><span class="hl std">]</span> <span class="hl opt">-</span> <span class="hl std">se[i,j,</span><span class="hl num">1</span><span class="hl std">],</span>
    <span class="hl std">xat[i,j], mn[i,j,</span><span class="hl num">1</span><span class="hl std">]</span> <span class="hl opt">+</span> <span class="hl std">se[i,j,</span><span class="hl num">1</span><span class="hl std">],</span>
    <span class="hl kwc">angle</span> <span class="hl std">=</span> <span class="hl num">90</span><span class="hl std">,</span> <span class="hl kwc">code</span> <span class="hl std">=</span> <span class="hl num">3</span><span class="hl std">,</span> <span class="hl kwc">length</span> <span class="hl std">=</span> <span class="hl num">0.05</span><span class="hl std">)</span>
<span class="hl std">}}</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">2</span><span class="hl std">)</span>
<span class="hl kwd">box</span><span class="hl std">()</span>
<span class="hl kwd">mtext</span><span class="hl std">(</span><span class="hl str">&quot;Average amount invested&quot;</span><span class="hl std">,</span> <span class="hl kwc">side</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">line</span> <span class="hl std">=</span> <span class="hl num">3</span><span class="hl std">)</span>
<span class="hl kwd">legend</span><span class="hl std">(</span><span class="hl str">&quot;topleft&quot;</span><span class="hl std">,</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Individual&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Team&quot;</span><span class="hl std">),</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">22</span><span class="hl std">,</span> <span class="hl kwc">pt.bg</span> <span class="hl std">= rb,</span> <span class="hl kwc">pt.cex</span> <span class="hl std">=</span> <span class="hl num">2.5</span><span class="hl std">,</span> <span class="hl kwc">bty</span> <span class="hl std">=</span> <span class="hl str">&quot;n&quot;</span><span class="hl std">)</span>
<span class="hl kwd">plot</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl kwc">xlim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0.8</span><span class="hl std">,</span> <span class="hl num">6.2</span><span class="hl std">),</span> <span class="hl kwc">ylim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">80</span><span class="hl std">),</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;n&quot;</span><span class="hl std">,</span> <span class="hl kwc">axes</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">,</span> <span class="hl kwc">xlab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">,</span> <span class="hl kwc">ylab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">)</span>
<span class="hl kwd">abline</span><span class="hl std">(</span><span class="hl kwc">h</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">8</span> <span class="hl opt">*</span> <span class="hl num">10</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">=</span> <span class="hl str">&quot;lightgray&quot;</span><span class="hl std">)</span>
<span class="hl std">xat</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">barplot</span><span class="hl std">(mn[,,</span><span class="hl num">2</span><span class="hl std">],</span> <span class="hl kwc">beside</span> <span class="hl std">=</span> <span class="hl num">TRUE</span><span class="hl std">,</span> <span class="hl kwc">ylim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">80</span><span class="hl std">),</span>
  <span class="hl kwc">main</span> <span class="hl std">=</span> <span class="hl str">&quot;Older group&quot;</span><span class="hl std">,</span> <span class="hl kwc">names</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;SHORT&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;LONG&quot;</span><span class="hl std">),</span>
  <span class="hl kwc">col</span> <span class="hl std">= rb,</span> <span class="hl kwc">add</span> <span class="hl std">=</span> <span class="hl num">TRUE</span><span class="hl std">,</span> <span class="hl kwc">axes</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">)</span>
<span class="hl kwa">for</span><span class="hl std">(i</span> <span class="hl kwa">in</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">) {</span> <span class="hl kwa">for</span><span class="hl std">(j</span> <span class="hl kwa">in</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">) {</span>
  <span class="hl kwd">arrows</span><span class="hl std">(xat[i,j], mn[i,j,</span><span class="hl num">2</span><span class="hl std">]</span> <span class="hl opt">-</span> <span class="hl std">se[i,j,</span><span class="hl num">2</span><span class="hl std">],</span>
    <span class="hl std">xat[i,j], mn[i,j,</span><span class="hl num">2</span><span class="hl std">]</span> <span class="hl opt">+</span> <span class="hl std">se[i,j,</span><span class="hl num">2</span><span class="hl std">],</span>
    <span class="hl kwc">angle</span> <span class="hl std">=</span> <span class="hl num">90</span><span class="hl std">,</span> <span class="hl kwc">code</span> <span class="hl std">=</span> <span class="hl num">3</span><span class="hl std">,</span> <span class="hl kwc">length</span> <span class="hl std">=</span> <span class="hl num">0.05</span><span class="hl std">)</span>
<span class="hl std">}}</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">4</span><span class="hl std">)</span>
<span class="hl kwd">box</span><span class="hl std">()</span>
</pre></div>
</div><div class="rimage center"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbAAAAGwCAMAAAD/kMAYAAAC61BMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS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mKT/dMBVvAs0axV8q262W63u6NbdHWvwF0Z3SVg0anuwDmCTBrdKfCkXXqIOXK7idvZ3YJMGBVkvivzAi8yr3OQSdsFmbRTtpik82+kV7tbbLIJYAuJ5q703PyspKTknRLR5g2BW7s+yMmdJYF7J8jHFRcHOfmumOPgR+L2viAfsmFtkHOvHAy8yIOvBPnAwiDnXt4vJtl6QHp1puUmtxpsTT7RNB3PZ5CBNDdZB9jxvrXVzprWrggFTXOT9TytL3INC/qME5mQ1iYb/8IZRSSA2SyA2SyA2SyA2SyA2SyA2SyA2SyA2SzTwd5N69W/kKoSpJs10US1Dw1IHPepdJ2EBMeAbfQvCdd3SEjYYGDeiiTPG+98pVfslw6k+esXDOw5ap9VFmnuKlUzG6w6vpS+HnSA70XWw+cuvdez1HOdDYnSq9Khxib2boV3vtKYwb94tiL/nhra4fjaIos0dZXqmQ12uE8j0c7DzXuxdaQ8+OIEz3W+79TYWrDm+Uozpy+Wt+JQ/3rp+L+3WWSRpq5SPbPBGrMGLilppKr2TqezVzQVPCUPft9dvs7ZRXnUWrDm+UozTyZWSFvx9wcstUhTV6me+U86Ppjryvi6+ZN3/mJ56FQX+a+HuKuPUmvBmucrzaT146SteGYB0UMJcfkWWaTJq1TLbLA3C6VXf32keS82jZMH38jyXKfoDmotWPN80lZQzsvRtOVW+XhjvkUWaeoq1TMb7FCfo3Ry+jPNe3HppkUX6WPnPs91vulDrQVrnk/eioreV1P90Kcu0pG0fIss0tRVqmf6Q+KrqYmJD9XxJ2A19/V3Zu1rus4vnStaARYl/YWT3zyfvBW0pCPRzzN6Dbyz7FGLLNLcVaqGL5xtFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBsFsBs1v8DCFKQE2SRqvEAAAAASUVORK5CYII=" title="plot of chunk auto-report" alt="plot of chunk auto-report" class="plot" /></div><div class="rcode">
<div class="source"><pre class="knitr r"><span class="hl com">## Table 3 #####################################################################</span>

<span class="hl com">## separate regressions by st (== interactions of st with all regressors except twomale dummy and school fixed effects)</span>
<span class="hl std">tab3_m1</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">plm</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl std">st</span> <span class="hl opt">/</span> <span class="hl std">(yo</span> <span class="hl opt">*</span> <span class="hl std">lh</span> <span class="hl opt">+</span> <span class="hl std">male</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">*</span> <span class="hl std">age)</span> <span class="hl opt">+</span> <span class="hl std">twomale</span> <span class="hl opt">+</span> <span class="hl std">school,</span> <span class="hl kwc">data</span> <span class="hl std">= pmla,</span> <span class="hl kwc">model</span> <span class="hl std">=</span> <span class="hl str">&quot;pooling&quot;</span><span class="hl std">)</span>
<span class="hl std">tab3_m12</span><span class="hl kwb">&lt;-</span> <span class="hl kwd">plm</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl std">st</span> <span class="hl opt">/</span> <span class="hl std">(male</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">*</span> <span class="hl std">age)</span>           <span class="hl opt">+</span> <span class="hl std">twomale</span> <span class="hl opt">+</span> <span class="hl std">school,</span> <span class="hl kwc">data</span> <span class="hl std">= pmla,</span> <span class="hl kwc">model</span> <span class="hl std">=</span> <span class="hl str">&quot;pooling&quot;</span><span class="hl std">)</span>
<span class="hl std">tab3_m2</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">plm</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl std">st</span> <span class="hl opt">/</span> <span class="hl std">(male</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">*</span> <span class="hl std">age)</span>                     <span class="hl opt">+</span> <span class="hl std">school,</span> <span class="hl kwc">data</span> <span class="hl std">= pmla,</span> <span class="hl kwc">model</span> <span class="hl std">=</span> <span class="hl str">&quot;pooling&quot;</span><span class="hl std">)</span>
<span class="hl kwd">waldtest</span><span class="hl std">(tab3_m1, tab3_m12, tab3_m2,</span> <span class="hl kwc">vcov</span> <span class="hl std">= vcovBK)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Wald test
## 
## Model 1: invest ~ st/(yo * lh + male + yo * age) + twomale + school
## Model 2: invest ~ st/(male + yo * age) + twomale + school
## Model 3: invest ~ st/(male + yo * age) + school
##   Res.Df Df  Chisq Pr(&gt;Chisq)
## 1   3402                     
## 2   3406 -4 1.7565     0.7804
## 3   3407 -1 0.1074     0.7431
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com">## model table (via memisc)</span>
<span class="hl kwd">library</span><span class="hl std">(</span><span class="hl str">&quot;memisc&quot;</span><span class="hl std">)</span>
<span class="hl kwd">setSummaryTemplate</span><span class="hl std">(</span><span class="hl str">&quot;coeftest&quot;</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span>
  <span class="hl str">&quot;N&quot;</span> <span class="hl std">=</span> <span class="hl str">&quot;($N:d)&quot;</span>
<span class="hl std">))</span>

<span class="hl com">## Table 3 (note: memisc uses other significance star coding!)</span>
<span class="hl kwd">mtable</span><span class="hl std">(</span>
  <span class="hl str">&quot;1_single&quot;</span> <span class="hl std">=</span> <span class="hl kwd">cftable</span><span class="hl std">(tab3_m1,</span> <span class="hl str">&quot;single&quot;</span><span class="hl std">),</span>
  <span class="hl str">&quot;1_team&quot;</span> <span class="hl std">=</span> <span class="hl kwd">cftable</span><span class="hl std">(tab3_m1,</span> <span class="hl str">&quot;team&quot;</span><span class="hl std">),</span>
  <span class="hl str">&quot;2_single&quot;</span> <span class="hl std">=</span> <span class="hl kwd">cftable</span><span class="hl std">(tab3_m2,</span> <span class="hl str">&quot;single&quot;</span><span class="hl std">),</span>
  <span class="hl str">&quot;2_team&quot;</span> <span class="hl std">=</span> <span class="hl kwd">cftable</span><span class="hl std">(tab3_m2,</span> <span class="hl str">&quot;team&quot;</span><span class="hl std">)</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## Calls:
## 1_single: plm(formula = invest ~ st/(yo * lh + male + yo * age) + twomale + 
##     school, data = pmla, model = &quot;pooling&quot;)
## 1_team: plm(formula = invest ~ st/(yo * lh + male + yo * age) + twomale + 
##     school, data = pmla, model = &quot;pooling&quot;)
## 2_single: plm(formula = invest ~ st/(male + yo * age) + school, data = pmla, 
##     model = &quot;pooling&quot;)
## 2_team: plm(formula = invest ~ st/(male + yo * age) + school, data = pmla, 
##     model = &quot;pooling&quot;)
## 
## =================================================================
##                      1_single    1_team    2_single    2_team    
## -----------------------------------------------------------------
##   yoOlder             -0.718     18.596**   -0.473     11.684*   
##                       (4.165)    (6.629)    (3.164)    (4.669)   
##   lhSHORT             -0.435      0.333                          
##                       (3.969)    (5.024)                         
##   maleyes             10.300**   13.316*    10.221**   12.853**  
##                       (3.370)    (5.253)    (3.276)    (4.974)   
##   age                  0.396      1.741      0.394      1.646    
##                       (1.725)    (2.452)    (1.726)    (2.440)   
##   yoOlder x lhSHORT    0.406     -8.889                          
##                       (5.606)    (8.658)                         
##   yoOlder x age        4.575      3.584      4.572      3.609    
##                       (2.505)    (3.861)    (2.503)    (3.865)   
##   twomaleyes                     -1.589                          
##                                  (5.000)                         
## -----------------------------------------------------------------
##   N                  385        185        385        185        
## =================================================================
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com">## Figure 2 ####################################################################</span>
<span class="hl com">## model-based investment</span>
<span class="hl std">tab3_m2_lm</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">lm</span><span class="hl std">(</span><span class="hl kwd">terms</span><span class="hl std">(tab3_m2),</span> <span class="hl kwc">data</span> <span class="hl std">= pmla)</span>
<span class="hl std">nd2</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">expand.grid</span><span class="hl std">(</span>
  <span class="hl kwc">male</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(pmla</span><span class="hl opt">$</span><span class="hl std">male),</span>
  <span class="hl kwc">st</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(pmla</span><span class="hl opt">$</span><span class="hl std">st),</span>
  <span class="hl kwc">yo</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(pmla</span><span class="hl opt">$</span><span class="hl std">yo),</span>
  <span class="hl kwc">school</span> <span class="hl std">=</span> <span class="hl str">&quot;4&quot;</span>
<span class="hl std">)</span>
<span class="hl std">nd2</span><span class="hl opt">$</span><span class="hl std">age</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(pmla,</span> <span class="hl kwd">tapply</span><span class="hl std">(age, yo, mean))[nd2</span><span class="hl opt">$</span><span class="hl std">yo]</span>
<span class="hl std">nd2</span><span class="hl opt">$</span><span class="hl std">invest</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">predict</span><span class="hl std">(tab3_m2_lm, nd2)</span>
<span class="hl com">## exploratory version (already computed above)</span>
<span class="hl com"># nd2e &lt;- aggregate(invest ~ st + yo + male, data = pmla, FUN = mean)</span>

<span class="hl kwd">par</span><span class="hl std">(</span><span class="hl kwc">mfrow</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">),</span> <span class="hl kwc">mar</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">3</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">3</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">),</span> <span class="hl kwc">oma</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">4</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">3</span><span class="hl std">),</span> <span class="hl kwc">yaxs</span> <span class="hl std">=</span> <span class="hl str">&quot;r&quot;</span><span class="hl std">)</span>
<span class="hl std">rb</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">hcl</span><span class="hl std">(</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">260</span><span class="hl std">,</span> <span class="hl num">260</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">),</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">),</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">15</span><span class="hl std">,</span> <span class="hl num">60</span><span class="hl std">,</span> <span class="hl num">25</span><span class="hl std">,</span> <span class="hl num">70</span><span class="hl std">),</span> <span class="hl kwc">fixup</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">)</span>
<span class="hl std">gr</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">hcl</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">100</span><span class="hl std">)</span>
<span class="hl kwd">plot</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">data</span> <span class="hl std">= nd2e,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;n&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">main</span> <span class="hl std">=</span> <span class="hl str">&quot;Younger group&quot;</span><span class="hl std">,</span> <span class="hl kwc">axes</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">,</span> <span class="hl kwc">xlim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0.5</span><span class="hl std">,</span> <span class="hl num">2.5</span><span class="hl std">),</span> <span class="hl kwc">ylim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">40</span><span class="hl std">,</span> <span class="hl num">75</span><span class="hl std">),</span>
  <span class="hl kwc">xlab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">,</span> <span class="hl kwc">ylab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">)</span>
<span class="hl kwd">abline</span><span class="hl std">(</span><span class="hl kwc">h</span> <span class="hl std">=</span> <span class="hl kwd">seq</span><span class="hl std">(</span><span class="hl num">40</span><span class="hl std">,</span> <span class="hl num">75</span><span class="hl std">,</span> <span class="hl kwc">by</span> <span class="hl std">=</span> <span class="hl num">5</span><span class="hl std">),</span> <span class="hl kwc">col</span> <span class="hl std">=</span> <span class="hl str">&quot;lightgray&quot;</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">male</span> <span class="hl opt">==</span> <span class="hl str">&quot;yes&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd2e,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">2</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">male</span> <span class="hl opt">==</span> <span class="hl str">&quot;no&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd2e,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">4</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">male</span> <span class="hl opt">==</span> <span class="hl str">&quot;yes&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd2,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">1</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">male</span> <span class="hl opt">==</span> <span class="hl str">&quot;no&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd2,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">3</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">at</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Individual&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Team&quot;</span><span class="hl std">))</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">2</span><span class="hl std">)</span>
<span class="hl kwd">box</span><span class="hl std">()</span>
<span class="hl kwd">mtext</span><span class="hl std">(</span><span class="hl str">&quot;Amount invested&quot;</span><span class="hl std">,</span> <span class="hl kwc">side</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">line</span> <span class="hl std">=</span> <span class="hl num">3</span><span class="hl std">)</span>
<span class="hl kwd">legend</span><span class="hl std">(</span><span class="hl str">&quot;topleft&quot;</span><span class="hl std">,</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Male, predicted&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Male, observed&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Female, predicted&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Female, observed&quot;</span><span class="hl std">),</span>
  <span class="hl kwc">col</span> <span class="hl std">= rb,</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">),</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">17</span><span class="hl std">,</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl num">19</span><span class="hl std">),</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">,</span> <span class="hl kwc">bty</span> <span class="hl std">=</span> <span class="hl str">&quot;n&quot;</span><span class="hl std">)</span>
<span class="hl kwd">plot</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">data</span> <span class="hl std">= nd2e,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;n&quot;</span><span class="hl std">,</span> <span class="hl kwc">main</span> <span class="hl std">=</span> <span class="hl str">&quot;Older group&quot;</span><span class="hl std">,</span> <span class="hl kwc">axes</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">,</span>
  <span class="hl kwc">xlim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0.5</span><span class="hl std">,</span> <span class="hl num">2.5</span><span class="hl std">),</span> <span class="hl kwc">ylim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">40</span><span class="hl std">,</span> <span class="hl num">75</span><span class="hl std">),</span> <span class="hl kwc">xlab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">,</span> <span class="hl kwc">ylab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">)</span>
<span class="hl kwd">abline</span><span class="hl std">(</span><span class="hl kwc">h</span> <span class="hl std">=</span> <span class="hl kwd">seq</span><span class="hl std">(</span><span class="hl num">40</span><span class="hl std">,</span> <span class="hl num">75</span><span class="hl std">,</span> <span class="hl kwc">by</span> <span class="hl std">=</span> <span class="hl num">5</span><span class="hl std">),</span> <span class="hl kwc">col</span> <span class="hl std">=</span> <span class="hl str">&quot;lightgray&quot;</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">male</span> <span class="hl opt">==</span> <span class="hl str">&quot;yes&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd2e,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">2</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">male</span> <span class="hl opt">==</span> <span class="hl str">&quot;no&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd2e,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">4</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">male</span> <span class="hl opt">==</span> <span class="hl str">&quot;yes&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd2,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">1</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">male</span> <span class="hl opt">==</span> <span class="hl str">&quot;no&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd2,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">3</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">at</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Individual&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Team&quot;</span><span class="hl std">))</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">4</span><span class="hl std">)</span>
<span class="hl kwd">box</span><span class="hl std">()</span>
</pre></div>
</div><div class="rimage center"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbAAAAGwCAMAAAD/kMAYAAADAFBMVEUAAAABAQECAgIDAwMEBAQFBQUGBgYHBwcICAgJCQkKCgoLCwsMDAwNDQ0ODg4PDw8QEBARERESEhITExMUFBQVFRUWFhYXFxcYGBgZGRkaGhobGxscHBwdHR0eHh4fHx8gICAhISEiIiIjIyMkJCQlJSUmJiYnJycoKCgpKSkqKiorKyssLCwtLS0uLi4vLy8wMDAxMTEyMjIzMzM0NDQ1NTU2NjY3Nzc4ODg5OTk6Ojo7Ozs8PDw9PT0+Pj4/Pz9AQEBBQUFCQkJDQ0NERERFRUVGRkZHR0dISEhJSUlKSkpLS0tMTExNTU1OTk5PT09QUFBRUVFSUlJTU1NUVFRVVVVWVlZXV1dYWFhZWVlaWlpbW1tcXFxdXV1eXl5fX19gYGBhYWFiYmJjY2NkZGRlZWVmZmZnZ2doaGhpaWlqampra2tsbGxtbW1ubm5vb29wcHBxcXFycnJzc3N0dHR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C8EYc4VdyJXlAhXmhAqToMKIoY+wKySnhGzW6iHIOoLhVGzryJXlgj7CKMSgwkwGFWYyqDCTQYWZDCrMZFBhJoMKMxnkhQXKFi0aHR/Xkv8gvI12CRy5BX7Cfregh+8OClpMonoi5qilAloLK7zGfxDesJsCgGPPqa+ZHHPUUgEthO148+Pug8tK33nypW7xOwa12QqsNRMGCZsrhgPQ9bBtaFDDLzCaYuqTod8DIXNSrzebTX6/62D/rqUCmgh7oBCE75vVw5oewDbF3I/Ali47BgmbQlMce9V6+5E85KZYH34r78UtQuakWuXZdxwHjc/7dS0V0ERYFwAG7eizDoAubFNkPwGGs2/CptAUIHvV+HuykJvi86fbtaszQ8ic1BeAmgD0OOzXtVRAE2GDuKboux6At9g2AG0O1bm9Y5CwyTVF08N7Qn/8pwF6U3wVBYDdLmRO6g9AkDphJqilAtoJm93bdq0G1xRzXx4CdgwSNte3tKfeeXjKF+DC/enITbGn6e3SJruFzKSEGbuWCmgl7L0DpW+HtBy7lv2cfdc2timEzaI+zw74MPlsu6avf/oe+s/5t/WemAqEzGJTDDzp17VUgN44mwwqzGRQYSaDCjMZVJjJoMJMBhVmMqgwk0GFmQwqzGRQYSaDCjMZVJjJoMJMBhVmMqgwk0GFmQwqzGRQYSaDCjMZVJjJoMJMxv8DcgbcasPhQe0AAAAASUVORK5CYII=" title="plot of chunk auto-report" alt="plot of chunk auto-report" class="plot" /></div><div class="rcode">
<div class="source"><pre class="knitr r"><span class="hl com">## Table 4 #####################################################################</span>

<span class="hl std">tab4_m1</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">plm</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl std">st</span> <span class="hl opt">/</span> <span class="hl std">(male</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">*</span> <span class="hl std">age)</span>                <span class="hl opt">+</span> <span class="hl std">school,</span> <span class="hl kwc">data</span> <span class="hl std">= pmla1,</span> <span class="hl kwc">model</span> <span class="hl std">=</span> <span class="hl str">&quot;pooling&quot;</span><span class="hl std">)</span>
<span class="hl std">tab4_m2</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">plm</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl std">st</span> <span class="hl opt">/</span> <span class="hl std">(male</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">*</span> <span class="hl std">age</span> <span class="hl opt">+</span> <span class="hl std">lwin</span> <span class="hl opt">+</span> <span class="hl std">cwin )</span> <span class="hl opt">+</span> <span class="hl std">school,</span> <span class="hl kwc">data</span> <span class="hl std">= pmla1,</span> <span class="hl kwc">model</span> <span class="hl std">=</span> <span class="hl str">&quot;pooling&quot;</span><span class="hl std">)</span>
<span class="hl kwd">waldtest</span><span class="hl std">(tab4_m1, tab4_m2,</span> <span class="hl kwc">vcov</span> <span class="hl std">= vcovBK)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Wald test
## 
## Model 1: invest ~ st/(male + yo * age) + school
## Model 2: invest ~ st/(male + yo * age + lwin + cwin) + school
##   Res.Df Df  Chisq Pr(&gt;Chisq)    
## 1   2837                         
## 2   2833  4 97.984  &lt; 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl kwd">mtable</span><span class="hl std">(</span>
  <span class="hl str">&quot;1_single&quot;</span> <span class="hl std">=</span> <span class="hl kwd">cftable</span><span class="hl std">(tab4_m1,</span> <span class="hl str">&quot;single&quot;</span><span class="hl std">),</span>
  <span class="hl str">&quot;1_team&quot;</span> <span class="hl std">=</span> <span class="hl kwd">cftable</span><span class="hl std">(tab4_m1,</span> <span class="hl str">&quot;team&quot;</span><span class="hl std">),</span>
  <span class="hl str">&quot;2_single&quot;</span> <span class="hl std">=</span> <span class="hl kwd">cftable</span><span class="hl std">(tab4_m2,</span> <span class="hl str">&quot;single&quot;</span><span class="hl std">),</span>
  <span class="hl str">&quot;2_team&quot;</span> <span class="hl std">=</span> <span class="hl kwd">cftable</span><span class="hl std">(tab4_m2,</span> <span class="hl str">&quot;team&quot;</span><span class="hl std">)</span>
<span class="hl std">)</span>
</pre></div>
<div class="output"><pre class="knitr r">## 
## Calls:
## 1_single: plm(formula = invest ~ st/(male + yo * age) + school, data = pmla1, 
##     model = &quot;pooling&quot;)
## 1_team: plm(formula = invest ~ st/(male + yo * age) + school, data = pmla1, 
##     model = &quot;pooling&quot;)
## 2_single: plm(formula = invest ~ st/(male + yo * age + lwin + cwin) + school, 
##     data = pmla1, model = &quot;pooling&quot;)
## 2_team: plm(formula = invest ~ st/(male + yo * age + lwin + cwin) + school, 
##     data = pmla1, model = &quot;pooling&quot;)
## 
## ==============================================================
##                  1_single    1_team    2_single     2_team    
## --------------------------------------------------------------
##   maleyes          9.844**   12.693*   10.006**    12.869*    
##                   (3.500)    (5.441)   (3.504)     (5.486)    
##   yoOlder         -1.526      9.442    -1.487       9.017     
##                   (3.441)    (5.066)   (3.441)     (5.072)    
##   age             -0.174      1.271    -0.307       1.373     
##                   (1.881)    (2.647)   (1.884)     (2.648)    
##   yoOlder x age    4.818      4.581     4.810       4.689     
##                   (2.733)    (4.156)   (2.733)     (4.167)    
##   lwin                                 -6.700***  -19.761***  
##                                        (1.604)     (2.287)    
##   cwin                                  2.415*      2.634     
##                                        (0.973)     (1.458)    
## --------------------------------------------------------------
##   N              385        185       385         185         
## ==============================================================
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com"># test for differences in short- and long-sighted effects</span>
<span class="hl std">tab4_m2_lh</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">plm</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl std">st</span> <span class="hl opt">/</span> <span class="hl std">(male</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">*</span> <span class="hl std">age</span> <span class="hl opt">+</span> <span class="hl std">lh</span> <span class="hl opt">*</span> <span class="hl std">(lwin</span> <span class="hl opt">+</span> <span class="hl std">cwin))</span>   <span class="hl opt">+</span> <span class="hl std">school,</span> <span class="hl kwc">data</span> <span class="hl std">= pmla1,</span> <span class="hl kwc">model</span> <span class="hl std">=</span> <span class="hl str">&quot;pooling&quot;</span><span class="hl std">)</span>
<span class="hl kwd">waldtest</span><span class="hl std">(tab4_m2, tab4_m2_lh,</span> <span class="hl kwc">vcov</span> <span class="hl std">= vcovBK)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Wald test
## 
## Model 1: invest ~ st/(male + yo * age + lwin + cwin) + school
## Model 2: invest ~ st/(male + yo * age + lh * (lwin + cwin)) + school
##   Res.Df Df Chisq Pr(&gt;Chisq)
## 1   2833                    
## 2   2827  6 6.995     0.3213
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl std">tab4_m2_ge</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">plm</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl std">st</span> <span class="hl opt">/</span> <span class="hl std">(male</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">*</span> <span class="hl std">age</span> <span class="hl opt">+</span> <span class="hl std">male</span> <span class="hl opt">*</span> <span class="hl std">(lwin</span> <span class="hl opt">+</span> <span class="hl std">cwin))</span> <span class="hl opt">+</span> <span class="hl std">school,</span> <span class="hl kwc">data</span> <span class="hl std">= pmla1,</span> <span class="hl kwc">model</span> <span class="hl std">=</span> <span class="hl str">&quot;pooling&quot;</span><span class="hl std">)</span>
<span class="hl kwd">waldtest</span><span class="hl std">(tab4_m2, tab4_m2_ge,</span> <span class="hl kwc">vcov</span> <span class="hl std">= vcovBK)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Wald test
## 
## Model 1: invest ~ st/(male + yo * age + lwin + cwin) + school
## Model 2: invest ~ st/(male + yo * age + male * (lwin + cwin)) + school
##   Res.Df Df  Chisq Pr(&gt;Chisq)
## 1   2833                     
## 2   2829  4 5.5484     0.2355
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl std">tab4_m2_yo</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">plm</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl std">st</span> <span class="hl opt">/</span> <span class="hl std">(male</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">*</span> <span class="hl std">age</span> <span class="hl opt">+</span> <span class="hl std">yo</span> <span class="hl opt">*</span> <span class="hl std">(lwin</span> <span class="hl opt">+</span> <span class="hl std">cwin))</span>   <span class="hl opt">+</span> <span class="hl std">school,</span> <span class="hl kwc">data</span> <span class="hl std">= pmla1,</span> <span class="hl kwc">model</span> <span class="hl std">=</span> <span class="hl str">&quot;pooling&quot;</span><span class="hl std">)</span>
<span class="hl kwd">waldtest</span><span class="hl std">(tab4_m2, tab4_m2_yo,</span> <span class="hl kwc">vcov</span> <span class="hl std">= vcovBK)</span>
</pre></div>
<div class="output"><pre class="knitr r">## Wald test
## 
## Model 1: invest ~ st/(male + yo * age + lwin + cwin) + school
## Model 2: invest ~ st/(male + yo * age + yo * (lwin + cwin)) + school
##   Res.Df Df  Chisq Pr(&gt;Chisq)
## 1   2833                     
## 2   2829  4 4.0474     0.3996
</pre></div>
<div class="source"><pre class="knitr r"><span class="hl com">## Figure 3 ####################################################################</span>

<span class="hl std">tab4_m3_lm</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">lm</span><span class="hl std">(</span><span class="hl kwd">terms</span><span class="hl std">(tab4_m2),</span> <span class="hl kwc">data</span> <span class="hl std">= pmla1)</span>
<span class="hl std">nd3</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">expand.grid</span><span class="hl std">(</span>
  <span class="hl kwc">lwin</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl opt">:</span><span class="hl num">1</span><span class="hl std">,</span>
  <span class="hl kwc">cwin</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">3</span><span class="hl std">),</span>
  <span class="hl kwc">st</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(pmla1</span><span class="hl opt">$</span><span class="hl std">st),</span>
  <span class="hl kwc">yo</span> <span class="hl std">=</span> <span class="hl kwd">levels</span><span class="hl std">(pmla1</span><span class="hl opt">$</span><span class="hl std">yo),</span>
  <span class="hl kwc">school</span> <span class="hl std">=</span> <span class="hl str">&quot;4&quot;</span>
<span class="hl std">)</span>
<span class="hl std">nd3</span><span class="hl opt">$</span><span class="hl std">male</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">factor</span><span class="hl std">(</span><span class="hl kwd">rep</span><span class="hl std">(</span><span class="hl str">&quot;yes&quot;</span><span class="hl std">,</span> <span class="hl kwd">nrow</span><span class="hl std">(nd3)),</span> <span class="hl kwc">levels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;no&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;yes&quot;</span><span class="hl std">))</span>
<span class="hl std">nd3</span><span class="hl opt">$</span><span class="hl std">age</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">with</span><span class="hl std">(pmla1,</span> <span class="hl kwd">tapply</span><span class="hl std">(age, yo, mean))[nd3</span><span class="hl opt">$</span><span class="hl std">yo]</span>
<span class="hl std">nd3</span><span class="hl opt">$</span><span class="hl std">invest</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">predict</span><span class="hl std">(tab4_m3_lm, nd3)</span>

<span class="hl kwd">par</span><span class="hl std">(</span><span class="hl kwc">mfrow</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">),</span> <span class="hl kwc">mar</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">3</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">3</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">),</span> <span class="hl kwc">oma</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">4</span><span class="hl std">,</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">3</span><span class="hl std">))</span>
<span class="hl com"># rb &lt;- hcl(c(0, 260), 90, 40, fixup = FALSE)</span>
<span class="hl std">rb</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">hcl</span><span class="hl std">(</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0</span><span class="hl std">,</span> <span class="hl num">260</span><span class="hl std">),</span> <span class="hl num">0</span><span class="hl std">,</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">15</span><span class="hl std">,</span> <span class="hl num">45</span><span class="hl std">),</span> <span class="hl kwc">fixup</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">)</span>
<span class="hl kwd">plot</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;n&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">main</span> <span class="hl std">=</span> <span class="hl str">&quot;Younger group&quot;</span><span class="hl std">,</span> <span class="hl kwc">axes</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">,</span> <span class="hl kwc">xlim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0.5</span><span class="hl std">,</span> <span class="hl num">2.5</span><span class="hl std">),</span> <span class="hl kwc">ylim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">44</span><span class="hl std">,</span> <span class="hl num">82</span><span class="hl std">),</span>
  <span class="hl kwc">xlab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">,</span> <span class="hl kwc">ylab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">)</span>
<span class="hl kwd">abline</span><span class="hl std">(</span><span class="hl kwc">h</span> <span class="hl std">=</span> <span class="hl kwd">seq</span><span class="hl std">(</span><span class="hl num">40</span><span class="hl std">,</span> <span class="hl num">85</span><span class="hl std">,</span> <span class="hl kwc">by</span> <span class="hl std">=</span> <span class="hl num">5</span><span class="hl std">),</span> <span class="hl kwc">col</span> <span class="hl std">=</span> <span class="hl str">&quot;lightgray&quot;</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">lwin</span> <span class="hl opt">==</span> <span class="hl num">0</span> <span class="hl opt">&amp;</span> <span class="hl std">cwin</span> <span class="hl opt">&lt;=</span> <span class="hl num">2</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">1</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">lwin</span> <span class="hl opt">==</span> <span class="hl num">0</span> <span class="hl opt">&amp;</span> <span class="hl std">cwin</span> <span class="hl opt">&gt;</span>  <span class="hl num">2</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">1</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">lwin</span> <span class="hl opt">==</span> <span class="hl num">1</span> <span class="hl opt">&amp;</span> <span class="hl std">cwin</span> <span class="hl opt">&lt;=</span> <span class="hl num">2</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">2</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Younger&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">lwin</span> <span class="hl opt">==</span> <span class="hl num">1</span> <span class="hl opt">&amp;</span> <span class="hl std">cwin</span> <span class="hl opt">&gt;</span>  <span class="hl num">2</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">2</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">at</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Individual&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Team&quot;</span><span class="hl std">))</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">2</span><span class="hl std">)</span>
<span class="hl kwd">box</span><span class="hl std">()</span>
<span class="hl kwd">mtext</span><span class="hl std">(</span><span class="hl str">&quot;Amount invested&quot;</span><span class="hl std">,</span> <span class="hl kwc">side</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">line</span> <span class="hl std">=</span> <span class="hl num">3</span><span class="hl std">)</span>
<span class="hl kwd">legend</span><span class="hl std">(</span><span class="hl str">&quot;topleft&quot;</span><span class="hl std">,</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Short-sight = 0, Long-sight = 3&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Short-sight = 0, Long-sight = 1&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Short-sight = 1, Long-sight = 3&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Short-sight = 1, Long-sight = 1&quot;</span><span class="hl std">),</span>
  <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">)],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl num">2</span><span class="hl std">),</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">17</span><span class="hl std">,</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl num">19</span><span class="hl std">),</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">,</span> <span class="hl kwc">bty</span> <span class="hl std">=</span> <span class="hl str">&quot;n&quot;</span><span class="hl std">)</span>
<span class="hl kwd">plot</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;n&quot;</span><span class="hl std">,</span>
  <span class="hl kwc">main</span> <span class="hl std">=</span> <span class="hl str">&quot;Older group&quot;</span><span class="hl std">,</span> <span class="hl kwc">axes</span> <span class="hl std">=</span> <span class="hl num">FALSE</span><span class="hl std">,</span> <span class="hl kwc">xlim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">0.5</span><span class="hl std">,</span> <span class="hl num">2.5</span><span class="hl std">),</span> <span class="hl kwc">ylim</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">44</span><span class="hl std">,</span> <span class="hl num">82</span><span class="hl std">),</span>
  <span class="hl kwc">xlab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">,</span> <span class="hl kwc">ylab</span> <span class="hl std">=</span> <span class="hl str">&quot;&quot;</span><span class="hl std">)</span>
<span class="hl kwd">abline</span><span class="hl std">(</span><span class="hl kwc">h</span> <span class="hl std">=</span> <span class="hl kwd">seq</span><span class="hl std">(</span><span class="hl num">40</span><span class="hl std">,</span> <span class="hl num">85</span><span class="hl std">,</span> <span class="hl kwc">by</span> <span class="hl std">=</span> <span class="hl num">5</span><span class="hl std">),</span> <span class="hl kwc">col</span> <span class="hl std">=</span> <span class="hl str">&quot;lightgray&quot;</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">lwin</span> <span class="hl opt">==</span> <span class="hl num">0</span> <span class="hl opt">&amp;</span> <span class="hl std">cwin</span> <span class="hl opt">&lt;=</span> <span class="hl num">2</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">1</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">lwin</span> <span class="hl opt">==</span> <span class="hl num">0</span> <span class="hl opt">&amp;</span> <span class="hl std">cwin</span> <span class="hl opt">&gt;</span>  <span class="hl num">2</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">17</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">1</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">lwin</span> <span class="hl opt">==</span> <span class="hl num">1</span> <span class="hl opt">&amp;</span> <span class="hl std">cwin</span> <span class="hl opt">&lt;=</span> <span class="hl num">2</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">2</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">lines</span><span class="hl std">(invest</span> <span class="hl opt">~</span> <span class="hl kwd">as.numeric</span><span class="hl std">(st),</span> <span class="hl kwc">subset</span> <span class="hl std">= yo</span> <span class="hl opt">==</span> <span class="hl str">&quot;Older&quot;</span> <span class="hl opt">&amp;</span> <span class="hl std">lwin</span> <span class="hl opt">==</span> <span class="hl num">1</span> <span class="hl opt">&amp;</span> <span class="hl std">cwin</span> <span class="hl opt">&gt;</span>  <span class="hl num">2</span><span class="hl std">,</span>
  <span class="hl kwc">data</span> <span class="hl std">= nd3,</span> <span class="hl kwc">type</span> <span class="hl std">=</span> <span class="hl str">&quot;b&quot;</span><span class="hl std">,</span> <span class="hl kwc">pch</span> <span class="hl std">=</span> <span class="hl num">19</span><span class="hl std">,</span> <span class="hl kwc">col</span> <span class="hl std">= rb[</span><span class="hl num">2</span><span class="hl std">],</span> <span class="hl kwc">lty</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">lwd</span> <span class="hl std">=</span> <span class="hl num">1.5</span><span class="hl std">)</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">1</span><span class="hl std">,</span> <span class="hl kwc">at</span> <span class="hl std">=</span> <span class="hl num">1</span><span class="hl opt">:</span><span class="hl num">2</span><span class="hl std">,</span> <span class="hl kwc">labels</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl str">&quot;Individual&quot;</span><span class="hl std">,</span> <span class="hl str">&quot;Team&quot;</span><span class="hl std">))</span>
<span class="hl kwd">axis</span><span class="hl std">(</span><span class="hl num">4</span><span class="hl std">)</span>
<span class="hl kwd">box</span><span class="hl std">()</span>
</pre></div>
</div><div class="rimage center"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAbA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vrNoVz8+DVi5r5fjB+c+glcINt32gus3Xa/77HzVrLqVxeC7YOEoIWgsrdOYVcP6DfSoAONaQ/MiEsHGUELQQtqPX4Dd6lhR/VKv16yt3dH/hN1BWY3V35+LP/QB4LaW8b82wcRinYmKt0C+Bs/Ket3o1i/30tZ6BfZQQNBF2XyFouT+hY1l2Ff5UzB0AtnXY0d256DwVx94ssz58HflUbGqZf73FNmflPY+W5t7xO4jAnTLJxlFC0ERYBwC67+i8EYAO/KnIfQr04/9xLjpPBchdP/qfFuRTMfLpdu2C452V97wDQA0AOuImPGTjKCFoIqy7/VS8swmAD/hzAF44HGzd0d25aD8VTVP2hn6VWh/9VEz42p7Yz1l5T1cAapIJY+AoIWgnbNbb5Rer20/F3Da9wY7uzsVNrWx/35kSNw6cvicb+VTsbWotbrzbWZmWMGMfJQSthPU5WPxhSKsRv/A/596VzJ8K5+LNzg3e+yztVLum70f3Qf86/6LuUxOBs7LrVHQ7EdBHCcF8cGYMUxhjmMIYwxTGGKYwxjCFMYYpjDFMYYxhCmMMUxhjmMIYwxTGGKYwxjCFMYYpjDFMYYxhCmMMUxhjmMIYwxTGGKYwxjCFMcb/Aw52REagQ85TAAAAAElFTkSuQmCC" title="plot of chunk auto-report" alt="plot of chunk auto-report" class="plot" /></div></div>
<div class="source"><pre class="knitr r"><span class="hl com">## Footnote 3 ##################################################################</span>

<span class="hl com">## subset with pocket money &gt; 0 and add centered age (within grade)</span>
<span class="hl std">mla0</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">subset</span><span class="hl std">(mla, pocketmoney</span> <span class="hl opt">&gt;</span> <span class="hl num">0</span><span class="hl std">)</span>
<span class="hl std">mla0</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">transform</span><span class="hl std">(mla0,</span>
  <span class="hl kwc">age_gr</span>   <span class="hl std">= age</span> <span class="hl opt">-</span> <span class="hl kwd">tapply</span><span class="hl std">(age, grade, mean)[</span><span class="hl kwd">factor</span><span class="hl std">(grade)]</span>
<span class="hl std">)</span>

<span class="hl com">## pocket money model</span>
<span class="hl std">pm</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">lm</span><span class="hl std">(</span><span class="hl kwd">log</span><span class="hl std">(pocketmoney)</span> <span class="hl opt">~</span> <span class="hl std">grade</span> <span class="hl opt">+</span> <span class="hl std">age_gr,</span> <span class="hl kwc">data</span> <span class="hl std">= mla0)</span>

<span class="hl com">## prediction different grades at mean age</span>
<span class="hl std">pm_pred</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">data.frame</span><span class="hl std">(</span><span class="hl kwc">grade</span> <span class="hl std">=</span> <span class="hl kwd">c</span><span class="hl std">(</span><span class="hl num">8</span><span class="hl std">,</span> <span class="hl num">10</span><span class="hl std">),</span> <span class="hl kwc">age_gr</span> <span class="hl std">=</span> <span class="hl num">0</span><span class="hl std">)</span>
<span class="hl std">pm_pred</span><span class="hl opt">$</span><span class="hl std">pocketmoney</span> <span class="hl kwb">&lt;-</span> <span class="hl kwd">exp</span><span class="hl std">(</span><span class="hl kwd">predict</span><span class="hl std">(pm,</span> <span class="hl kwc">newdata</span> <span class="hl std">= pm_pred))</span>
<span class="hl std">pm_pred</span>
</pre></div>
<div class="output"><pre class="knitr r">##   grade age_gr pocketmoney
## 1     8      0    6.163148
## 2    10      0   10.983537
</pre></div>
</div></div>

  <p>The R session information (including the OS info, R version and all
    packages used):</p>

<div class="chunk" id="session-info"><div class="rcode"><div class="source"><pre class="knitr r">    <span class="hl kwd">sessionInfo</span><span class="hl std">()</span>
</pre></div>
<div class="output"><pre class="knitr r">## R version 3.5.1 (2018-07-02)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Debian GNU/Linux buster/sid
## 
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
## LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=C                 
##  [4] LC_COLLATE=C               LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
## [10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] memisc_0.99.14.9 MASS_7.3-50      lattice_0.20-35  car_3.0-0        carData_3.0-1   
##  [6] lmtest_0.9-36    zoo_1.8-3        plm_1.6-6        Formula_1.2-3    coin_1.2-2      
## [11] survival_2.43-3  knitr_1.20       fortunes_1.5-4  
## 
## loaded via a namespace (and not attached):
##  [1] tinytex_0.6       modeltools_0.2-22 xfun_0.3          repr_0.15.0      
##  [5] splines_3.5.1     haven_1.1.2       htmltools_0.3.6   stats4_3.5.1     
##  [9] base64enc_0.1-3   rlang_0.2.2       pillar_1.3.0      foreign_0.8-71   
## [13] readxl_1.1.0      multcomp_1.4-8    stringr_1.3.1     cellranger_1.1.0 
## [17] bdsmatrix_1.3-3   zip_1.0.0         mvtnorm_1.0-8     codetools_0.2-15 
## [21] evaluate_0.12     rio_0.5.10        miscTools_0.6-22  forcats_0.3.0    
## [25] curl_3.2          markdown_0.8      highr_0.7         TH.data_1.0-9    
## [29] Rcpp_0.12.19      abind_1.4-5       mime_0.5          maxLik_1.3-4     
## [33] digest_0.6.17     hms_0.4.2         stringi_1.2.4     openxlsx_4.1.0   
## [37] grid_3.5.1        tools_3.5.1       sandwich_2.5-0    magrittr_1.5     
## [41] tibble_1.4.2      crayon_1.3.4      pkgconfig_2.0.1   Matrix_1.2-14    
## [45] data.table_1.11.4 nlme_3.1-137      compiler_3.5.1
</pre></div>
<div class="source"><pre class="knitr r">    <span class="hl kwd">Sys.time</span><span class="hl std">()</span>
</pre></div>
<div class="output"><pre class="knitr r">## [1] &quot;2018-12-06 10:12:05 CET&quot;
</pre></div>
</div></div>


</body>
</html>
